Search Java Code Snippets


  Help us in improving the repository. Add new snippets through 'Submit Code Snippet ' link.





#Java - Code Snippets for '#Java 9' - 11 code snippet(s) found

 Sample 1. Code to get Module name for the class

Module module = Test.class.getModule();
System.out.println(module.getName());

   Like      Feedback     java 9  java 9 module


 Sample 2. Code to get all packages of a Module

public class Test {
   public static void main(String[] args) {
      Module module = Test.class.getModule();
      System.out.println(module.getPackages());
   }   
}

   Like      Feedback     java 9  java 9 module


 Sample 3. Code to get Module name for List class

Module module = java.util.List.class.getModule();
System.out.println(module.getName()); // prints java.base

   Like      Feedback     java 9  java 9 module


 Sample 4. Code to print all packages of a module

Module module = java.util.List.class.getModule();
System.out.println(module.getPackages());

   Like      Feedback     java 9  java 9 modules


Subscribe to Java News and Posts. Get latest updates and posts on Java from Buggybread.com
Enter your email address:
Delivered by FeedBurner
 Sample 5. Code to get exports of a particular Module

Module module = java.util.List.class.getModule();
ModuleDescriptor moduleDescriptor = module.getDescriptor();
System.out.println(moduleDescriptor.exports());

   Like      Feedback     java 9  java 9 modules  get exports for a module


 Sample 6. Code to get ModuleDescriptor from a particular Module

Module module = java.util.List.class.getModule();
ModuleDescriptor moduleDescriptor = module.getDescriptor();

   Like      Feedback     java 9  java 9 modules  get ModuleDescriptor for a module


 Sample 7. Code to get main class in a particular module

Module module = java.util.List.class.getModule();
ModuleDescriptor moduleDescriptor = module.getDescriptor();
System.out.println(moduleDescriptor.mainClass());

   Like      Feedback     java 9  java 9 modules  get main class for a module  get main class for a module in java 9  java module


 Sample 8. Usage of JavaBean Annotation

@JavaBean(description = "",defaultProperty="",defaultEventSet="")
public class Test {
}

   Like      Feedback     JavaBean Annotation  java 9


 Sample 9. Initializing a list using factory method in java 9

Usage of List.of()

List<String> countryList = List.of("France","Belgium","Germany");

   Like      Feedback     java 9


Subscribe to Java News and Posts. Get latest updates and posts on Java from Buggybread.com
Enter your email address:
Delivered by FeedBurner
 Sample 10. Initializing a map using factory method in java 9

Usage of Map.of()

Map<String,String> countryCodeMap = Map.of("France","FR","United States","US","Canada","CA");

   Like      Feedback     java 9


 Sample 11. Code Sample for

jdk.jshell.JShell;
jdk.jshell.MethodSnippet;
jdk.jshell.Snippet;

JShell.Builder builder =
    JShell.builder()
    .in(System.in)
    .out(System.out)
    .err(System.out);
      
JShell jshell = builder.build();
      
System.out.println(jshell.snippets()
.filter(sn -> sn.kind() == Snippet.Kind.METHOD)
.map(sn -> (MethodSnippet) sn).findFirst().get().signature());

   Like      Feedback     java 9  java 9 Jshell  Jshell



Subscribe to Java News and Posts. Get latest updates and posts on Java from Buggybread.com
Enter your email address:
Delivered by FeedBurner